package demo3;

public class PersonDemo {
    public static void main(String[] args) {
        //method01();
        //method02();
        //method03();

        Person person = new Person();
        person.setName("芷若");
        person.setAge(30);
        System.out.println(person.getName() + " " + person.getAge());
        person.eat();
    }

  /*  private static void method03() {
        Person p = new Person();
        p.name = "无忌";
        //p.age = 13;//外部无法直接使用age成员变量,就无法随意的给age赋值
        // p.setAge(-20);
        p.setAge(30);

        p.eat();
    }*/

/*    private static void method02() {
        Person p = new Person();
        p.name = "无忌";
        //p.age = -30; //这段代码从语法角度和运行角度都没问题
        //但是不符合客观规律,现实生活中不可能有负值年龄

        p.eat();
        System.out.println(p.name+" "+p.age);
    }*/

/*    public static void method01() {
        Person p = new Person();
        p.name = "赵敏";
        p.age = 20;
        p.eat();
    }*/
}


